package ac.github.os.internal.core.action.player

import ac.github.os.internal.core.action.IEntityAction
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.session.Cache
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake
import taboolib.common5.Coerce

@Awake
class TitleAction : IEntityAction {
    override fun onExecute(session: Session, cache: Cache, config: StringConfig) {
        val main = config.get("main", "")!!
        val sub = config.get("sub", "")!!
        val list = config.get("args", listOf("0", "0", "0"))!!.map { Coerce.toInteger(it) }
        cache.filterIsPlayers().forEach {
            it.sendTitle(main, sub, list[0], list[1], list[2])
        }

    }

    override val namespace: String
        get() = "player:title"
}